/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller.commands;

import java.awt.Color;
import model.graphic.objects.GBoxNode;
import model.graphic.objects.Attachment;
import model.graphic.objects.GNode;
import model.graphic.objects.Graphical;

/**
 *
 * @author Jelle
 */
public class ColorCommand extends BasicCommand {

    private Color color;
    private Graphical g;

    public ColorCommand(Color color, Graphical g) {
        this.color = color;
        this.g = g;
    }

    @Override
    public void execute() {
            if (GNode.class.isAssignableFrom(g.getClass())) {
                GNode node = (GNode) g;
                node.setBaseColor(color);
                Color hcolor = color.brighter().brighter();
                node.setHighLightColor(hcolor);
                for (Attachment gr : gmodel.getAttachedAllNode(node)) {
                    gr.setBaseColor(color);
                    gr.setHighLightColor(hcolor);
                }
            } else if (GBoxNode.class.isAssignableFrom(g.getClass())) {
                GBoxNode bn = (GBoxNode) g;
                bn.setBaseColor(color);
                Color hcolor = color.brighter().brighter();
                bn.setHighLightColor(hcolor);
                for (Graphical gr : bn.getInternalObjects()) {
                    gr.setBaseColor(color);
                    gr.setHighLightColor(hcolor);
                }
                for (Graphical gr : bn.getTransmitterObjects()) {
                    gr.setBaseColor(color);
                    gr.setHighLightColor(hcolor);
                }
            } else {
                g.setBaseColor(color);
            }
    }
}
